package com.lee.singleton;

/**
 * 功能描述:
 *
 * @author liping(lpaidd50@gmail.com)
 * @version v1.0
 * @date 2017/3/24
 */
public class Main {
	public static void main(String[] args) throws InterruptedException {
		Singleton aSingleton = Singleton.getInstance();
		Singleton bSingleton = Singleton.getInstance();
		if (bSingleton == aSingleton) {
			System.out.println("singleton ok");
		} else {
			System.out.println("singleton fail");
		}

		final SyncSingleton aSyncSingleton = SyncSingleton.getInstance();
		Thread.sleep(1000L);
		Thread thread = new Thread(new Runnable() {
			public void run() {
				SyncSingleton bSyncSingleton = SyncSingleton.getInstance();
				if (aSyncSingleton == bSyncSingleton) {
					System.out.println("sync singleton ok");
				} else {
					System.out.println("sync singleton fail");
				}
			}
		});
		thread.start();


	}
}
